//
//  HEMyOrderHeadCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2020/11/5.
//  Copyright © 2020 honglutec. All rights reserved.
//

#import "HEMyOrderHeadCell.h"

@interface HEMyOrderHeadCell ()


@end

@implementation HEMyOrderHeadCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
         self.backgroundColor = [UIColor clearColor];

         self.selectionStyle = UITableViewCellSelectionStyleNone;
         [self initUI];
         
         UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectClick)];
         [self.contentView addGestureRecognizer:tap];
     }
     return self;;
 }

- (void)selectClick {
    if (self.tapClickBlock) {
        self.tapClickBlock();
    }
    if ([_delegate respondsToSelector:@selector(headSelect:)]) {
        [_delegate headSelect: _model];
    }
}

- (void)initUI {
    
    UIView *warp = [UIView new];
    warp.backgroundColor = KWhiteColor;
    [self.contentView addSubview:warp];

    [warp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(10);
        make.left.equalTo(self.contentView).mas_offset(10);
        make.right.equalTo(self.contentView).mas_offset(-10);
//        make.height.mas_greaterThanOrEqualTo(15);
        make.bottom.equalTo(self.contentView).mas_offset(0);
    }];
    [warp hg_setCornerOnTopWithRadius:10.0f];
    
    // 订单号
    _orderSnLb = [UILabel new];
    _orderSnLb.text = @"订单号：-";
    _orderSnLb.font = DYFont(15);
    [warp addSubview:_orderSnLb];
    
    // 订单状态
    _statusLb = [UILabel new];
    _statusLb.text = @"-";
    _statusLb.textColor = CNavBgColor;
    _statusLb.font = DYFont(15);
    [warp addSubview:_statusLb];
    
    UIView *headLine = [UIView new];
    headLine.backgroundColor = CSplitLineColor;
    [warp addSubview:headLine];
    
    [_orderSnLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(warp).mas_offset(15);
        make.left.equalTo(warp).mas_offset(10);
        make.right.equalTo(_statusLb.mas_left).mas_offset(-5);
    }];
    
    [_statusLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_orderSnLb);
        make.right.equalTo(warp).mas_offset(-10);
    }];
    [_statusLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    
    [headLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_orderSnLb.mas_bottom).mas_offset(10);
        make.height.mas_offset(1);
        make.left.equalTo(warp).mas_offset(15);
        make.right.equalTo(warp).mas_offset(-10);
        make.bottom.equalTo(warp).mas_offset(-15);
    }];
}

- (void)setModel:(HEOrderModel *)model {
    _model = model;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
